Repository navigation
Conversation
MenAtCafe
force-pushed
the
keyboard-map
branch
3 times, most recently
from
November 15, 2026 06:19
a54e374 to
a7ca288
Compare
The Mac front end's key map was a switch on virtual key codes: A B X Y on J K U I, arrows on the D-pad, and no keys at all for the right stick, which left a 3D game's camera to Shift + arrows or a controller. pad_kbd.h holds the map as a table, 25 actions with up to four keys each, and parses an override in the shape DM_HID_MAP already uses. front_mac.m keeps one bitmask of held actions and the action each key code went down as, so an arrow pressed with Shift still comes back up as the right stick it went down as. The default map is the one that was compiled in, so nothing changes for a player who does not set the variable. 44 checks in dm/host/tests/t_pad_kbd.c, a row in docs/env_switches.tsv and a paragraph in docs/playing.md. Front-ends: new: DM_KBD_MAP, a configurable keyboard map in env.txt
MenAtCafe
force-pushed
the
keyboard-map
branch
from
November 18, 2026 04:05
a7ca288 to
8ad3ab8
Compare
Owner
|
Thanks for the keyboard map and the 44 focused checks. I’m closing this older implementation in favor of #3141, which proposes a shared controls file for configurable keyboard bindings and controller remaps. Main still has a fixed keyboard map. The key-release case from this PR is worth carrying into that work. When an arrow is pressed with Shift and released after Shift goes up, the release still has to clear the right-stick action. |
chgpalmer
added a commit
to chgpalmer/nxnative
that referenced
this pull request
Nov 29, 2026
The Mac front end's half of the controller mapping (host/input: keymap.h, the remap in hle_hid.c): - In the game (front_mac.m, keyboard_mac.h): the keyboard goes through the map in place of the fixed key table, Shift, Control and Option keys included (flagsChanged). Each player's controller table goes to the host (dm_pad_map_set) at the start and after every change. - The mouse (mouselook_mac.h): with a mouse direction bound, a click on the game captures the pointer and its movement goes through keymap_mouse.h at 120 Hz, to player 1's sticks and buttons, or to the motion sensor as a controller turned in the hands (dm_motion_set_switch: upright in handheld mode, flat docked). Esc, a focus loss or the panel lets it go. - The settings window (Launcher.swift): Controls › Controller mapping › Customize…: a tab per player 1-8; player 1 has its keyboard and mouse or its controller; click a row and press a key or chord, click a mouse button, or press a controller's button or push its stick; right-click for Clear, Add Input… or a mouse direction; Mouse and trackpad puts the mouse on a stick or the motion controls with its sensitivity and Invert Y axis; a Preset menu per device (keymap_presets.h). Kept as the saved choice launcher.DM_KEYMAP, which launcher.c checks with the host's parser. - In the game, Window › Controller Mapping… (⌘⇧K, keymap_panel_mac.h) is the same map while playing: a change applies at once and is saved for the next start. - pad_apple.h's dm_pad_state is now the one reading of a GameController pad as the Switch's, used by the host's pad_read and the settings window's press-to-bind (pad_bridge.m). Covers seedds#2346 (mouse as a stick), seedds#2392's and seedds#356's asks (mouse look, the camera on plain arrows), the keyboard part of seedds#386 and seedds#2006's modifier keys; keys are tracked as pressed, so Shift let go before an arrow does not leave the right stick held (seedds#1535). Tests: test_launcher_storage (the window with the sheet's model), test_nsp_mac_app, test_docs, test_env_switches. Front-ends: new: launcher.DM_KEYMAP is a saved choice, checked by the host's parser (docs/frontends.md, Saved choices) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Mac keyboard has no right stick. A 3D game's camera can only be turned with Shift and the arrow keys, or with a controller, which leaves the keyboard unusable for anything that needs a camera. The map is also a switch on virtual key codes inside
front_mac.m, so changing one key means editing C.pad_kbd.hholds the map as a table: 25 actions, up to four keys each, with the layout that was compiled in as the default, so nothing changes for a player who sets nothing.DM_KBD_MAPoverrides it in the shapeDM_HID_MAPalready uses (A=C,B=X,RSTICK_UP=I), and a named action's keys are replaced rather than added to.front_mac.mkeeps one bitmask of the actions held and one byte per key code recording the action it went down as, so an arrow pressed with Shift still comes back up as the right stick it went down as, whatever Shift does meanwhile.push()now reads that bitmask, which removes the old key-code switch and the nine globals it fed.Tests:
dm/host/tests/t_pad_kbd.chas 44 checks over the default map, the override, alternates and a key that moves between actions.Checked on a rebase onto today's
main: the Mac host builds, the host unit tests pass, andtest_env_switches,test_docs,test_lint_c,test_lint_pythonandtest_architecturepass.Front-ends: new:
DM_KBD_MAP, a configurable keyboard map inenv.txt